package DAO;

import java.sql.*;
import java.util.Properties;
import Interface.IDAOFactory;

public abstract class DAOFactory implements IDAOFactory{

    Connection conn = null;
    ResultSet resultSet = null;
    Statement statement = null;
    
    public DAOFactory() {
        try{
            Properties parametros = new Properties();
            parametros.load(DAOFactory.class.getResourceAsStream("app.properties"));

            String driver = StaticParametros.getParametros().getDriver();
            String bdCaminho = StaticParametros.getParametros().getbdCaminho();

            Class.forName(driver);

            conn = DriverManager.getConnection(bdCaminho);
            System.out.println("Conexão realizada com sucesso.");
        }
        catch (Exception e) {
            System.out.println(e.getMessage());
        }   
    }
    
    public void CloseConnection()
    {
        try {
            this.resultSet.close();
            this.statement.close();
            this.conn.close();
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }
}
